<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialCostOrder from '@/api/financial/financialCostOrder'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  financialCostOrder.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  financialCostOrder.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_financial_cost_order',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: financialCostOrder.getList,
  recycleApi: financialCostOrder.getRecycleList,
  add: {
    show: true,
    api: financialCostOrder.save,
    auth: ['financial:costOrder:save']
  },
  edit: {
    show: true,
    api: financialCostOrder.update,
    auth: ['financial:costOrder:update']
  },
  delete: {
    show: true,
    api: financialCostOrder.deletes,
    auth: ['financial:costOrder:delete'],
    realApi: financialCostOrder.realDeletes,
    realAuth: ['financial:costOrder:realDeletes']
  },
  recovery: {
    show: true,
    api: financialCostOrder.recoverys,
    auth: ['financial:costOrder:recovery']
  },
  import: {
    show: true,
    url: 'financial/costOrder/import',
    templateUrl: 'financial/costOrder/downloadTemplate',
    auth: ['financial:costOrder:import']
  },
  export: {
    show: true,
    url: 'financial/costOrder/export',
    auth: ['financial:costOrder:export']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "支付订单号",
    dataIndex: "pay_order_id",
    formType: "input",
    search: true
  },
  {
    title: "订单号",
    dataIndex: "order_number",
    formType: "input",
    search: true
  },
  {
    title: "类型",
    dataIndex: "type",
    formType: "select",
    search: true,
    dict: {
      data: [
        {
          label: "到货",
          value: "1"
        },
        {
          label: "发货",
          value: "2"
        }
      ],
      translation: true
    }
  },
  {
    title: "公司",
    dataIndex: "dept_id",
    formType: "input",
    search: true
  },
  {
    title: "客户名称",
    dataIndex: "user_id",
    formType: "input",
    search: true
  },
  {
    title: "发货id",
    dataIndex: "send_id",
    formType: "input",
    search: true
  },
  {
    title: "预报单",
    dataIndex: "prediction_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "提货订单",
    dataIndex: "prediction_order_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "装车单ID",
    dataIndex: "prediction_driver_order_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "支付项目",
    dataIndex: "pay_items_json",
    formType: "input",
    hide: true
  },
  {
    title: "税额",
    dataIndex: "tax_price",
    formType: "input",
    search: true
  },
  {
    title: "不含税价",
    dataIndex: "no_tax_price",
    formType: "input",
    search: true
  },
  {
    title: "总计支付金额",
    dataIndex: "pay_price",
    formType: "input",
    search: true
  },
  {
    title: "实际支付金额",
    dataIndex: "pay_real_price",
    formType: "input",
    search: true
  },
  {
    title: "支付日期",
    dataIndex: "pay_date",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "提货订单号",
    dataIndex: "prediction_order_number",
    formType: "input",
    search: true
  },
  {
    title: "是否分账",
    dataIndex: "is_fz",
    formType: "select",
    search: true,
    dict: {
      data: [
        {
          label: "未分账",
          value: "0"
        },
        {
          label: "已分账",
          value: "1"
        }
      ],
      translation: true
    }
  },
  {
    title: "合同号ID",
    dataIndex: "contract_id",
    formType: "input",
    search: true
  },
  {
    title: "是否已结算",
    dataIndex: "is_jiesuan",
    formType: "input",
    search: true
  },
  {
    title: "集装箱ID",
    dataIndex: "box_id",
    formType: "input",
    search: true
  },
  {
    title: "是否已确认",
    dataIndex: "is_confirm",
    formType: "select",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    dict: {
      data: [
        {
          label: "待确认",
          value: "0"
        },
        {
          label: "已确认",
          value: "1"
        }
      ],
      translation: true
    }
  },
  {
    title: "确认人",
    dataIndex: "confirm_user",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "确认时间",
    dataIndex: "confirm_time",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "支付部门id",
    dataIndex: "pay_dept_id",
    formType: "input",
    search: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "修改时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'financial:costOrder' } </script>